-
Notifications
You must be signed in to change notification settings - Fork 184
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix logging levels and go micro default log level #4102
Conversation
Thanks for opening this pull request! The maintainers of this repository would appreciate it if you would create a changelog item based on your changes. |
💥 Acceptance test cs3ApiTests-ocis failed. Further test are cancelled... |
ocis-pkg/log/gomicro/log.go
Outdated
// this is ugly, but "logger.DefaultLogger" is a global variable and we need to set it _before_ anybody uses it | ||
setMicroLogger() | ||
} | ||
|
||
// for logging reasons we don't want the same logging level on both oCIS and micro. As a framework builder we do not | ||
// want to expose to the end user the internal framework logs unless explicitly specified. | ||
func setMicroLogger() { | ||
if os.Getenv("MICRO_LOG_LEVEL") == "" { | ||
_ = os.Setenv("MICRO_LOG_LEVEL", "error") | ||
} | ||
|
||
lev, err := zerolog.ParseLevel(os.Getenv("MICRO_LOG_LEVEL")) | ||
if err != nil { | ||
lev = zerolog.ErrorLevel | ||
} | ||
logger.DefaultLogger = mzlog.NewLogger( | ||
logger.WithLevel(logger.Level(lev)), | ||
logger.WithFields(map[string]interface{}{ | ||
"system": "go-micro", | ||
}), | ||
) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am not entirely sure if it works, but wouldn't it be easier to just add this to ocis-pkg/log/log.go? That way it should be possible to also get rid of all the blank ocis-pkg/log/gomicro
imports. Or am I missing anything?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for changing this. I tested with your changes and it still works
Kudos, SonarCloud Quality Gate passed! |
@rhafer I also removed leftovers from the runtime. The |
Description
We've fixed the configuration of logging levels. Previously it was not possible
to configure a service with a more or less verbose log level then all other services
when running in the supervised / runtime mode
ocis server
.For example
OCIS_LOG_LEVEL=error PROXY_LOG_LEVEL=debug ocis server
did not configureerror logging for all services except the proxy, which should be on debug logging. This is now fixed
and working properly.
Also we fixed the format of go-micro logs to always default to error level.
Previously this was only ensured in the supervised / runtime mode.
Related Issue
Motivation and Context
How Has This Been Tested?
Screenshots (if appropriate):
Types of changes
Checklist: